package com.leanit.pmc.center.user;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 */
@Service
public class CenterSerivce {
    @Autowired
    private CenterDao centerDao;

    @Transactional(readOnly = false)
    public void updateOperateInfo(String loginName, String userName, String identityNo, String phoneNo) {
        centerDao.updateIdNo(loginName,identityNo);
        centerDao.updateUserName(loginName, userName,phoneNo);
    }

    @Transactional(readOnly = true)
    public Map getUserInfo(String loginName) {
        List reList=centerDao.getUserInfo(loginName);
        if(null!=reList&&reList.size()>0){
            return (HashMap)reList.get(0);
        }else{
            return null;
        }
    }

    @Transactional(readOnly = false)
    public String getIdNo(String logName) {
        String idNo = centerDao.getIdNo(logName);
        if (StringUtils.isEmpty(idNo)) {
            centerDao.insertIdNo(logName);
            idNo = "";
        }
        return idNo;
    }
}
